package multithreading.Demo7_Thread8Blocl;

public class Seventh
{

    /**
     *  同一个对象(类)，同一个级别，会竞争锁资源
     */
    public static void main(String[] args) {

        Number7 number = new Number7();

        new Thread(new Runnable() {
            @Override
            public void run() {
                try {
                    Number7.getOne();
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
        }).start();

        new Thread(new Runnable() {
            @Override
            public void run() {
                Number7.getTwo();
            }
        }).start();
    }


}

class Number7{
    public static synchronized void getOne() throws InterruptedException {
        Thread.sleep(3000);
        System.out.println("=====one=====");
    }
    public static synchronized void getTwo(){
        System.out.println("=====two=====");
    }
}
